package com.example.experiment05.repository;

import com.example.experiment05.dto.UserAddress03;
import com.example.experiment05.entity.User;
import com.example.experiment05.mapper.UserAddress03RowMapper;
import org.springframework.data.jdbc.repository.query.Modifying;
import org.springframework.data.jdbc.repository.query.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;

@Repository
public interface UserRepository extends CrudRepository<User, Long> {
    @Modifying
    @Query("update user set name=:name where id = :id")
    Boolean updateUserNameById(Long id,String name);

    @Query(value = "select * from address a join user u on u.id = a.user_id where a.user_id=:uid",
            resultSetExtractorClass = UserAddress03RowMapper.class)
    UserAddress03 findUserAddresById(long uid);
}
